package com.funo.logic.service;

import cn.hutool.json.JSONUtil;
import com.funo.logic.model.SingleOperateConfig;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 单数据操作配置
 * @since 2024年7月25日22:15:35
 * @author cms
 */
@Service
public class SingleOperateConfigService extends AbstractService {

    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    public SingleOperateConfig getByBelongNodeId(@RequestParam String belongNodeId) {
        String cacheKey = getCacheKey(belongNodeId);
        String value = stringRedisTemplate.opsForValue().get(cacheKey);
        if (StringUtils.isBlank(value)) {
            return null;
        }
        return JSONUtil.toBean(value, SingleOperateConfig.class);
    }

    @Override
    public String getCachePrefix() {
        return "singleOperateConfig:";
    }
}
